package com.ailanyin.soft.utils;

import cn.hutool.core.util.RuntimeUtil;

/**
 * 安装 Redis
 *
 * @author ailanyin
 * @version 1.0
 * @since 2022-1-10 13:45:03
 */
public class RedisUtil {

    public static void installRedis() {
        System.out.println("========== 开始安装 Redis rpm ==========");
        RuntimeUtil.getResult(RuntimeUtil.exec("yum install -y http://rpms.famillecollet.com/enterprise/remi-release-7.rpm"));
        System.out.println("========== 成功安装 Redis rpm ==========");

        System.out.println("========== 开始安装 Redis ==========");
        RuntimeUtil.getResult(RuntimeUtil.exec("yum --enablerepo=remi install redis -y"));
        System.out.println("========== 成功安装 Redis ==========");

        RuntimeUtil.getResult(RuntimeUtil.exec("systemctl restart redis"));
        System.out.println("========== 成功启动 Redis ==========");

        RuntimeUtil.getResult(RuntimeUtil.exec("systemctl enable redis"));
        System.out.println("========== 设置 Redis 开机自启完成 ==========");
    }
}
